package com.gitee.wsl.mathematics.vector

import com.gitee.wsl.mathematics.vector.vec2.Vec2f
import com.gitee.wsl.mathematics.vector.vec3.Vec3f
import com.gitee.wsl.mathematics.vector.vec4.Vec4f
import kotlin.math.sqrt
import kotlin.test.Test
import kotlin.test.assertEquals

class LengthTest {
    @Test
    fun vec2_length() = assertEquals(sqrt(13f), Vec2f(2f, 3f).length)

    @Test
    fun vec3_length() = assertEquals(sqrt(29f), Vec3f(2f, 3f, 4f).length)

    @Test
    fun vec4_length() = assertEquals(sqrt(54f), Vec4f(2f, 3f, 4f, 5f).length)

    @Test
    fun vec2_sqrLength() = assertEquals(13f, Vec2f(2f, 3f).squaredLength)

    @Test
    fun vec3_sqrLength() = assertEquals(29f, Vec3f(2f, 3f, 4f).squaredLength)

    @Test
    fun vec4_sqrLength() = assertEquals(54f, Vec4f(2f, 3f, 4f, 5f).squaredLength)
}